package com.boang.web;

import com.boang.po.Page;
import com.boang.po.Student;
import com.boang.service.StuServiceImpl;
import jakarta.servlet.RequestDispatcher;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

/*
  @author: 13813
  @date: 2024/7/17 9:12
*/
@WebServlet("/stu")
public class StuServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        int pageNum = Integer.parseInt(req.getParameter("pageNum"));
        int pageSize = Integer.parseInt(req.getParameter("pageSize"));
        StuServiceImpl stuService = new StuServiceImpl();
        Page<Student> page = stuService.getStuList(pageNum, pageSize);

        req.setAttribute("page", page);
        RequestDispatcher dispatcher = req.getRequestDispatcher("stu.jsp");
        dispatcher.forward(req, resp);
    }
}
